package com.example.demo.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Auth;
import com.example.demo.entity.Role;
import com.example.demo.mapper.AuthMapper;
import com.example.demo.service.RoleService;
import com.example.demo.mapper.RoleMapper;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author 三石
* @description 针对表【role(角色表)】的数据库操作Service实现
* @createDate 2024-05-06 21:39:48
*/
@Service
@AllArgsConstructor
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService{

    private AuthMapper authMapper;

    @Resource
    private RoleMapper roleMapper;

    @Override
    public List<String> findAuthByIds(List<Long> roleIds) {
        if(ObjectUtil.isEmpty(roleIds)){
            return Collections.emptyList();
        }
        List<Long> authIds = baseMapper.selectAuthorIdsByIds(roleIds);
        return authMapper.selectUriByIds(authIds);
    }

    @Override
    public String getRoleNameByRoleId(Long roleId) {
        Role role = roleMapper.selectById(roleId);

        return role.getRolename();
    }

}




